layui.use(['form', 'jquery', 'layer', 'table', 'laydate', 'laypage'], function() {
	var form = layui.form;
	var $ = layui.$;
	var table = layui.table;
	var layer = layui.layer;
	var laydate = layui.laydate;
	var laypage = layui.laypage;

	var table_filter = 'yujing_list',
		where_json = {
			_o: 'yujing_id',
			_b: 'asc',
			type_index:-1
			
		},
		form_filter = 'yujing_search_form';

	// 渲染表格
	layer.load();
	table.render({
		elem: '#' + table_filter,
		id: table_filter,
		url: yujing_list_url,
		method: 'post',
		height: 'full-200',
		where: {
			_o: 'yujing_id',
			_b: 'asc',
			type_index: -1
		},
		defaultToolbar: ['filter'],
		cols: [yujing_cols],
		page: {
			layout: ['count', 'first', 'prev', 'page', 'next', 'last', 'skip'],
			limit: 20,
			theme: '#393d49',
			groups: 8
		},
		autoSort: false,
		toolbar: false,
		initSort: {
			field: 'yujing_id',
			type: 'asc'
		},
		done: function() {
			layer.closeAll();
		}
	});
	// 点击查看详情
	table.on('row(' + table_filter + ')', function(obj) {
		var get_site_id = $('form[lay-filter="order_search_form"]').find('select[name="site_id"]')
			.val(),
			content_url = order_detail_url + '?order_no=' + obj.data.order_no;
		if (get_site_id != undefined && get_site_id != '') {
			content_url = content_url + '&site_id=' + get_site_id;
		}
		var node_obj = document.elementFromPoint(event.clientX, event.clientY);
		if ($(node_obj).hasClass('layui-icon-ok') == false) {
			layer.open({
				type: 2,
				anim: -1,
				title: '订单详情',
				closeBtn: true,
				offset: 'r',
				shade: 0.3,
				move: false,
				shadeClose: false,
				area: '90%',
				skin: "layui-anim layui-anim-rl layui-layer-adminRight",
				content: content_url
			})
		}
		return false;
	})
	form.render();
	form.on('radio', function(data) {
		var value = data.value;
		var e = data.elem;
		var name = $(e).attr('name');
		select_search(name, value);
	});
	var select_search = function(field, value) {
		var where = {};
		where[field] = value;
		where_json[field] = value;
		table.reload(table_filter, {
			where: where,
			page: {
				curr: 1
			}
		});
	};
	// 表格工具监听
	table.on('tool(' + table_filter + ')', function(obj) {
		var data = obj.data;
		var e = obj.event;
		var tr = obj.tr;
		var yujing_id = data.yujing_id;
		switch (e) {
			default:
				break;
		}
	})
});
